package com.juyu.miliao.api.controller;

import com.juyu.miliao.api.domain.dto.FakeUserDTO;
import com.juyu.miliao.api.service.FakeUserService;
import com.juyu.miliao.common.exception.ConsumeRuntimeException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author jh
 * 2018/10/19
 */
@RestController
@RequestMapping(value = "/vest/ranking")
@Api(tags = "马甲包排行", value = "马甲包排行")
public class FakeUserController {

    @Resource
    private FakeUserService fakeUserService;

    @ApiOperation(value = "获取马甲包排行", produces = MediaType.APPLICATION_JSON_VALUE)
    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public List<FakeUserDTO> list(@ApiParam(value = "1-魅力榜 2-贡献榜", required = true) @RequestParam Integer type) {
        if (!(type == 1 || type == 2)) {
            throw new ConsumeRuntimeException("type只能为1或2");
        }
        return fakeUserService.list(type);
    }

}
